import Vue from 'vue';
import Vuex from 'vuex';
import client from './client';
import routeParam from './routeParam';
import ide from './ide';
import request from './request';
Vue.use(Vuex);

export default new Vuex.Store({
  modules: {
    client,
    routeParam,
    ide,
    request
  },
  mutations: {
    clearStore(state) {
      state.routeParam.routeParamState = {};
      state.ide.freezeMode = false;
      state.ide.draggingWidget = undefined;
      state.ide.selectWidgetIds = [];
    }
  },
  actions: {
    clearStore({commit}) {
      return new Promise(resolve => {
        commit('clearStore');
        resolve();
      });
    }
  }
});
